home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 23
/
Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso
/
Aminet
/
dev
/
amos
/
AMOS1097.lzh
/
AMOSLIST
/
000048_amos-request@svcs1.digex.net_Fri Oct 3 08:39:28 1997.msg
< prev
next >
Wrap
Internet Message Format
|
1997-11-02
|
2KB
Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224])
by mail2.access.digex.net (8.8.5/8.8.5) with ESMTP id IAA22552
for <mcox@access.digex.net>; Fri, 3 Oct 1997 08:39:26 -0400 (EDT)
Received: (from daemon@localhost)
by svcs1.digex.net (8.8.5/8.8.5) id HAA01378
for amos-out; Fri, 3 Oct 1997 07:20:08 -0400 (EDT)
Received: from mail2.access.digex.net (mail2.access.digex.net [205.197.247.3])
by svcs1.digex.net (8.8.5/8.8.5) with ESMTP id HAA01375
for <amos-list@svcs1.digex.net>; Fri, 3 Oct 1997 07:20:07 -0400 (EDT)
Received: from MCSDEV.MCS.CO.UK (SYSTEM@mcsdev.mcs.co.uk [193.32.50.112])
by mail2.access.digex.net (8.8.5/8.8.5) with SMTP id HAA14165
for <amos-list@access.digex.net>; Fri, 3 Oct 1997 07:20:05 -0400 (EDT)
Date: Fri, 3 Oct 1997 09:57 GMT
From: "SIMONC%MARS.decnet"@mcs.co.uk (Simon Champion - simonc@mcs.co.uk)
Message-Id: <009BB36B2C28DDE0.153D@mcs.co.uk>
To: amos-list@access.digex.net
Subject: Re: Sorting routine
X-VMS-To: MCSDEV::SMTP%"amos-list@access.digex.net"
Status: O
X-Status:
Subj: Re: Sorting routine.
>Hi!
>Is there a smooth way to sort 20 variables???
>and not do like this..
>--------------------------------
>If score1_1(1)>score2_1(1)
> Loke S7+40,Leek(S5+20)
>endif
>if score1_2(2)>score2_1(1)
> loke s7+60,leek(s5+40)
>endif
>-------------------------------
>This way makes the program very big..!
>Any soloution anyone????
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There's loads of different methods of sorting an array.
Most of them use loops. The quickest ones use recursion.
I'm sure there's a "Sort" command in Amos. I recall ever having
used it, but I'm sure it's there.
If you can't use that, try this:
cnt - loop counter
cnt2 - second loop counter
siz - number of array elements
srt() - the array to sort
tmp - a temporary var to hold a copy of one srt().
For cnt=1 to siz-1
For cnt2=cnt+1 to siz
Rem Out of sequence?
If srt(cnt) > srt(cnt2)
Rem then swap the two variables.
tmp=srt(cnt)
srt(cnt)=srt(cnt2)
srt(cnt2)=tmp
Endif
Next
Next
A recursive 'quick sort' would be much quicker, but isn't easy to
understand like this one.
Hope that answers your question.
See ya.
SimonC.